home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 145 / Gekkan Dennou Club - 2000.6 Vol. 145 (Japan).7z / Gekkan Dennou Club - 2000.6 Vol. 145 (Japan) (Track 1).bin / games / spassion / source.lzh / SOURCE / FuncEnemy / BOSS04.C < prev    next >
Text File  |  2000-03-27  |  12KB  |  303 lines

  1. /*
  2. #include <stdio.h>
  3. #include <iocslib.h>
  4. void    key_wait( void );
  5. #define BIT(i)        (1<<(i))
  6. */
  7. /*
  8. 背景にぶつかり跳ね返る
  9. */
  10. #include <xsp2lib.h>
  11. #include "../SPASSION.H"
  12. #include "../player.h"
  13. #include "../enemy.h"
  14. #include "../eshot.h"
  15. #include "../effect.h"
  16. #include "../priority.h"
  17. #include "../sound.h"
  18. #include "../entry.h"
  19. #ifndef NULL
  20. #define NULL ((void *) 0)
  21. #endif
  22.  
  23. #define PALET_MAIN    0x0700
  24.  
  25. static short MoveEnemyBoss04(ENEMY *);
  26. /*static void TiniEnemyBoss04(ENEMY *);*/
  27.  
  28. /* 上部分 */
  29. static HIT_XY4    hitup_p[5]={ -16-PLAYER_HIT_X, -16-PLAYER_HIT_Y, 16+PLAYER_HIT_X,   -10+PLAYER_HIT_Y,};
  30. static HIT_XY4    hitup_s[5]={ -16, -16, 16,   -12,};
  31. /* 下部分 */
  32. static HIT_XY4    hitdown_p[5]={ -16-PLAYER_HIT_X, 10-PLAYER_HIT_Y, 16+PLAYER_HIT_X,   16+PLAYER_HIT_Y,};
  33. static HIT_XY4    hitdown_s[5]={ -16, 12, 16,   16,};
  34.  
  35. /* 左上部分 */
  36. static HIT_XY4    hitleftup_p[5]={-18-PLAYER_HIT_X, -18-PLAYER_HIT_Y, -8+PLAYER_HIT_X, -8+PLAYER_HIT_Y,};
  37. static HIT_XY4    hitleftup_s[5]={-18, -18, -8, -8,};
  38. /* 右上部分 */
  39. static HIT_XY4    hitrightup_p[5]={8-PLAYER_HIT_X, -18-PLAYER_HIT_Y, 18+PLAYER_HIT_X, -8+PLAYER_HIT_Y,};
  40. static HIT_XY4    hitrightup_s[5]={8, -18, 18, -8,};
  41. /* 左下部分 */
  42. static HIT_XY4    hitleftdown_p[5]={-18-PLAYER_HIT_X, 8-PLAYER_HIT_Y, -8+PLAYER_HIT_X, 18+PLAYER_HIT_Y,};
  43. static HIT_XY4    hitleftdown_s[5]={-18, 8, -8, 18,};
  44. /* 右下部分 */
  45. static HIT_XY4    hitrightdown_p[5]={8-PLAYER_HIT_X, 8-PLAYER_HIT_Y, 18+PLAYER_HIT_X, 18+PLAYER_HIT_Y,};
  46. static HIT_XY4    hitrightdown_s[5]={8, 8, 18, 18,};
  47.  
  48. extern HIT_XY4    nohit;
  49. static unsigned char seed=0;
  50.  
  51. /* 当たり判定の初期化 */
  52. void InitEnemyBoss04Hit( void )
  53. {
  54.     short    i;
  55.     for(i=1;i<5;i++){
  56.         hitup_p[i].x1=  hitup_p[0].x1;  hitup_p[i].y1=  hitup_p[0].y1;  hitup_p[i].x2=  hitup_p[0].x2;  hitup_p[i].y2=  hitup_p[0].y2;
  57.         hitup_s[i].x1=  hitup_s[0].x1;  hitup_s[i].y1=  hitup_s[0].y1;  hitup_s[i].x2=  hitup_s[0].x2;  hitup_s[i].y2=  hitup_s[0].y2;
  58.         hitdown_p[i].x1=hitdown_p[0].x1;hitdown_p[i].y1=hitdown_p[0].y1;hitdown_p[i].x2=hitdown_p[0].x2;hitdown_p[i].y2=hitdown_p[0].y2;
  59.         hitdown_s[i].x1=hitdown_s[0].x1;hitdown_s[i].y1=hitdown_s[0].y1;hitdown_s[i].x2=hitdown_s[0].x2;hitdown_s[i].y2=hitdown_s[0].y2;
  60.  
  61.         hitleftup_p[i].x1=hitleftup_p[0].x1-i*4;hitleftup_p[i].y1=hitleftup_p[0].y1-i*4;
  62.         hitleftup_p[i].x2=hitleftup_p[0].x2-i*4;hitleftup_p[i].y2=hitleftup_p[0].y2-i*4;
  63.         hitrightup_p[i].x1=hitrightup_p[0].x1+i*4;hitrightup_p[i].y1=hitrightup_p[0].y1-i*4;
  64.         hitrightup_p[i].x2=hitrightup_p[0].x2+i*4;hitrightup_p[i].y2=hitrightup_p[0].y2-i*4;
  65.         hitleftdown_p[i].x1=hitleftdown_p[0].x1-i*4;hitleftdown_p[i].y1=hitleftdown_p[0].y1+i*4;
  66.         hitleftdown_p[i].x2=hitleftdown_p[0].x2-i*4;hitleftdown_p[i].y2=hitleftdown_p[0].y2+i*4;
  67.         hitrightdown_p[i].x1=hitrightdown_p[0].x1+i*4;hitrightdown_p[i].y1=hitrightdown_p[0].y1+i*4;
  68.         hitrightdown_p[i].x2=hitrightdown_p[0].x2+i*4;hitrightdown_p[i].y2=hitrightdown_p[0].y2+i*4;
  69.  
  70.         hitleftup_s[i].x1=hitleftup_s[0].x1-i*4;hitleftup_s[i].y1=hitleftup_s[0].y1-i*4;
  71.         hitleftup_s[i].x2=hitleftup_s[0].x2-i*4;hitleftup_s[i].y2=hitleftup_s[0].y2-i*4;
  72.         hitrightup_s[i].x1=hitrightup_s[0].x1+i*4;hitrightup_s[i].y1=hitrightup_s[0].y1-i*4;
  73.         hitrightup_s[i].x2=hitrightup_s[0].x2+i*4;hitrightup_s[i].y2=hitrightup_s[0].y2-i*4;
  74.         hitleftdown_s[i].x1=hitleftdown_s[0].x1-i*4;hitleftdown_s[i].y1=hitleftdown_s[0].y1+i*4;
  75.         hitleftdown_s[i].x2=hitleftdown_s[0].x2-i*4;hitleftdown_s[i].y2=hitleftdown_s[0].y2+i*4;
  76.         hitrightdown_s[i].x1=hitrightdown_s[0].x1+i*4;hitrightdown_s[i].y1=hitrightdown_s[0].y1+i*4;
  77.         hitrightdown_s[i].x2=hitrightdown_s[0].x2+i*4;hitrightdown_s[i].y2=hitrightdown_s[0].y2+i*4;
  78.     }
  79. }
  80.  
  81. void InitEnemyBoss04(ENEMY *ene)
  82. {
  83.     ene->vx = -1 * 65536;
  84.     ene->vy = 8 * 65536;
  85.     ene->hit_p[0] = &hitup_p[0];ene->hit_p[1] = &hitdown_p[0];
  86.     ene->hit_p[2] = &hitleftup_p[0];ene->hit_p[3] = &hitrightup_p[0];
  87.     ene->hit_p[4] = &hitleftdown_p[0];ene->hit_p[5] = &hitrightdown_p[0];
  88.     ene->hit_p[6]=NULL;
  89.     ene->hit_o[0] = &nohit;ene->hit_o[1] = &nohit;
  90.     ene->hit_o[2] = &nohit;ene->hit_o[3] = &nohit;
  91.     ene->hit_o[4] = &nohit;ene->hit_o[5] = &nohit;
  92.     ene->hit_o[6]=NULL;
  93.     ene->hit_s[0] = &hitup_s[0];ene->hit_s[1] = &hitdown_s[0];
  94.     ene->hit_s[2] = &hitleftup_s[0];ene->hit_s[3] = &hitrightup_s[0];
  95.     ene->hit_s[4] = &hitleftdown_s[0];ene->hit_s[5] = &hitrightdown_s[0];
  96.     ene->hit_s[6]=NULL;
  97.     ene->pt         = obj_boss4;
  98.     ene->info     = PALET_MAIN | PRIORITY_BOSS;
  99.     ene->angle     = 0;
  100.     ene->func_enemy_move = MoveEnemyBoss04;
  101. /*    ene->func_enemy_tini = TiniEnemyBoss04;*/
  102.     ene->parts1=MakeEnemy(ENEMY_CORE , ene->x  , ene->y, 2,  ene);
  103.     ene->parts1->parts1=MakeEnemy(ENEMY_SHIELD , ene->parts1->x-12, ene->parts1->y,0,  ene->parts1);
  104.     ene->parts1->parts2=MakeEnemy(ENEMY_SHIELD , ene->parts1->x+12, ene->parts1->y,1,  ene->parts1);
  105.  
  106.     ene->work=0;
  107.  
  108.     entry_counter_stop = !0;        /* エントリーカウンター停止 */
  109. }
  110.  
  111. static short MoveEnemyBoss04( ENEMY *ene )
  112. {
  113.     short    anim_num=0;
  114.     short Wait( ENEMY *ene, short time );
  115.  
  116.     /* 爆発 */
  117.     if( ene->dead_count ){
  118.         ene->dead_count++;
  119.         if( ene->y > 256+40+16 ){
  120.             ene->child_death=1;
  121.             if(!ene->parent){
  122.                 entry_counter_stop = 0;    /* エントリーカウンター停止解除 */
  123.                 return (0);        /* 消去 */
  124.             }else{                        /* ラスボスに呼び出された場合は解除しない */
  125.                 if( ene->child_kill )
  126.                     return (0);        /* 消去 */
  127.             }
  128.         }else{
  129.             if( !(ene->dead_count%20) ){
  130.                 short    exp_x,exp_y,x,y;
  131.                 exp_x=rndtable[seed++]&31;seed&=255;
  132.                 exp_y=rndtable[seed++]&31;seed&=255;
  133.                 if( rndtable[seed++]>128 ){exp_x*=-1;exp_y*=-1;seed&=255;}
  134.                 MakeEffect(EFFECT_EXPLMINI, 0, (x=ene->x+exp_x-8), (y=ene->y+exp_y-8));
  135.                 SetSE(SE_EXPL_MBOSS);    /* 爆発音 */
  136.                 if( !(ene->dead_count%60) ){
  137.                     MakeEffect(EFFECT_EXPL, 0, ene->x, ene->y);
  138.                     MakeEffect(EFFECT_HAHENMINI, 0, x, y);
  139.                     SetSE(SE_EXPL_BOSS);    /* 爆発音 */
  140.                 }
  141.             }
  142.             ene->y = (ene->ly += 65536/2) >> 16;
  143.             xobj_set_st(ene);
  144.             return (1);
  145.         }
  146.     }
  147.  
  148.     /* 速度を足して上位ワード(固定整数部)だけ取り出す */
  149.     /* 本体 */
  150.     ene->x = (ene->lx += ene->vx) >> 16;
  151.     ene->y = (ene->ly += ene->vy) >> 16;
  152.     /* コア */
  153.     ene->parts1->x=((ene->parts1->lx=ene->lx)>>16)-8;
  154.     ene->parts1->y=((ene->parts1->ly=ene->ly)>>16)-8;
  155.     /* シールド */
  156.     ene->parts1->parts1->x=((ene->parts1->parts1->lx=ene->parts1->lx-12*65536)>>16)-8;    /*-8は表示位置をずらすため*/
  157.     ene->parts1->parts1->y=((ene->parts1->parts1->ly=ene->parts1->ly         )>>16)-8;
  158.     ene->parts1->parts2->x=((ene->parts1->parts2->lx=ene->parts1->lx+12*65536)>>16)-8;    /*-8は表示位置をずらすため*/
  159.     ene->parts1->parts2->y=((ene->parts1->parts2->ly=ene->parts1->ly         )>>16)-8;
  160.  
  161.     map_x-=map_vx;
  162.     switch (ene->work){
  163.     case 0:        /* 登場 */
  164.         if( ENE_Y < 64+16 || ENE_Y > 192+16 ){
  165.             ene->vy*=-1;
  166.             SetSE(SE_ESHOT_PARABOLA);    /* ぶつかった音 */
  167.         }
  168.         if( ENE_X < 16+16 ){
  169.             ene->vx*=-1;
  170.             ene->count++;
  171.             ene->work++;
  172.             SetSE(SE_ESHOT_PARABOLA);    /* ぶつかった音 */
  173.         }
  174.         break;
  175.     case 1:
  176.         if( ENE_Y < 64+16 || ENE_Y > 192+16 ){
  177.             ene->vy*=-1;
  178.             SetSE(SE_ESHOT_PARABOLA);    /* ぶつかった音 */
  179.         }
  180.         if( ENE_X < 16+16 || ENE_X > 200+16 ){
  181.             ene->vx*=-1;
  182.             ene->count++;
  183.             SetSE(SE_ESHOT_PARABOLA);    /* ぶつかった音 */
  184.         }
  185.         if( ene->count > 0 && (ENE_X>112+16 && ENE_X<144+16) && (ENE_Y>124+16 && ENE_Y<132+16) ){
  186.             ene->move_ax=ene->vx;        /* 加速度保存 */
  187.             ene->move_ay=ene->vy;
  188.             ene->vx=0;
  189.             ene->vy=0;
  190.             ene->count=0;
  191.             ene->work++;
  192.         }
  193.         break;
  194.     case 2:        /* 時間稼ぎ */
  195.         if( Wait( ene, 20 ) )ene->work++;
  196.         break;
  197.     case 3:        /* 変形、コアのシャッターを開く */
  198.         anim_num=(++ene->anim_count)/8;
  199.         ene->pt = obj_boss4+anim_num;
  200.         ene->hit_p[2] = &hitleftup_p[anim_num];ene->hit_p[3] = &hitrightup_p[anim_num];ene->hit_p[4] = &hitleftdown_p[anim_num];ene->hit_p[5] = &hitrightdown_p[anim_num];
  201.         ene->hit_s[2] = &hitleftup_s[anim_num];ene->hit_s[3] = &hitrightup_s[anim_num];ene->hit_s[4] = &hitleftdown_s[anim_num];ene->hit_s[5] = &hitrightdown_s[anim_num];
  202.         ene->parts1->pt=obj_obj+anim_num;
  203.         if( anim_num == 4){
  204.                 SetSE(SE_TRANSFORM);    /* ガチャン */
  205.             ene->work++;
  206.         }
  207.         break;
  208.     case 4:        /* 拡散弾 */
  209.         if( !Wait( ene, 80 ) ){
  210.             if( ene->count == 20 ){
  211.                 if(level>=NOMAL){
  212.                     MakeEShot(ESHOT_HOMING, ENE_X+32, ENE_Y-32, 5, 32, 4,0,ene);MakeEShot(ESHOT_HOMING, ENE_X+32, ENE_Y-32,13, 32, 4,0,ene);
  213.                     MakeEShot(ESHOT_HOMING, ENE_X+32, ENE_Y+32, 5, 96, 4,0,ene);MakeEShot(ESHOT_HOMING, ENE_X+32, ENE_Y+32,13, 96, 4,0,ene);
  214.                     MakeEShot(ESHOT_HOMING, ENE_X-32, ENE_Y+32, 5,160, 4,0,ene);MakeEShot(ESHOT_HOMING, ENE_X-32, ENE_Y+32,13,160, 4,0,ene);
  215.                     MakeEShot(ESHOT_HOMING, ENE_X-32, ENE_Y-32, 5,224, 4,0,ene);MakeEShot(ESHOT_HOMING, ENE_X-32, ENE_Y-32,13,224, 4,0,ene);
  216.                     SetSE(SE_ESHOT_HOMING);    /* 敵ショット音 */
  217.                 }
  218.             }else if( ene->count == 40 ){
  219.                 MakeEShot(ESHOT_CUTTER, ENE_X+32, ENE_Y-32,13, 32, 4,0,ene);MakeEShot(ESHOT_CUTTER, ENE_X+32, ENE_Y-32,23, 32, 4,0,ene);
  220.                 MakeEShot(ESHOT_CUTTER, ENE_X+32, ENE_Y+32,13, 96, 4,0,ene);MakeEShot(ESHOT_CUTTER, ENE_X+32, ENE_Y+32,23, 96, 4,0,ene);
  221.                 MakeEShot(ESHOT_CUTTER, ENE_X-32, ENE_Y+32,13,160, 4,0,ene);MakeEShot(ESHOT_CUTTER, ENE_X-32, ENE_Y+32,23,160, 4,0,ene);
  222.                 MakeEShot(ESHOT_CUTTER, ENE_X-32, ENE_Y-32,13,224, 4,0,ene);MakeEShot(ESHOT_CUTTER, ENE_X-32, ENE_Y-32,23,224, 4,0,ene);
  223.                 if(level>=HARD){
  224.                     MakeEShot(ESHOT_CUTTER, ENE_X   , ENE_Y-32,13,  0, 4,0,ene);MakeEShot(ESHOT_CUTTER, ENE_X   , ENE_Y-32,23,  0, 4,0,ene);
  225.                     MakeEShot(ESHOT_CUTTER, ENE_X   , ENE_Y+32,13,128, 4,0,ene);MakeEShot(ESHOT_CUTTER, ENE_X   , ENE_Y+32,23,128, 4,0,ene);
  226.                 }
  227.                 SetSE(SE_ESHOT_CUTTER);        /* 敵ショット音 */
  228.             }else if( ene->count == 60 ){
  229.                 MakeEShot(ESHOT_PARACHUTE, ENE_X+32, ENE_Y-32,13, 16, 4,0,ene);
  230.                 MakeEShot(ESHOT_PARACHUTE, ENE_X+32, ENE_Y-32,13, 32, 4,0,ene);
  231.                 MakeEShot(ESHOT_PARACHUTE, ENE_X-32, ENE_Y-32,13,240, 4,0,ene);
  232.                 MakeEShot(ESHOT_PARACHUTE, ENE_X-32, ENE_Y-32,13,224, 4,0,ene);
  233.                 SetSE(SE_ESHOT_PARACHUTE);    /* 敵ショット音 */
  234.             }
  235.         }else{
  236.             SetSE(SE_ESHOT_SYURIKEN);        /* 次のショット音 */
  237.             ene->work++;
  238.         }
  239.         break;
  240.     case 5:
  241.         /* リング(大) */
  242.         if(level>=NOMAL){
  243.             MakeEShot(ESHOT_RING02, ENE_X, ENE_Y, 5, ene->angle, 4,0,ene);
  244.             if(level>=HARD)
  245.                 MakeEShot(ESHOT_PARABOLA, ENE_X, ENE_Y, 20, (ene->angle+8)&255, 4,0,ene);
  246.         }
  247.         if( (ene->angle+=16)>255 ){
  248.             ene->angle=0;
  249.             ene->work++;
  250.         }
  251.         break;
  252.     case 6:        /* 時間稼ぎ */
  253.         if( Wait( ene, 120 ) ){
  254.             ene->work++;
  255.         }
  256.         break;
  257.     case 7:        /* 変形、コアのシャッターを閉じる */
  258.         anim_num=(--ene->anim_count)/8;
  259.         ene->pt = obj_boss4+anim_num;
  260.         ene->hit_p[2] = &hitleftup_p[anim_num];ene->hit_p[3] = &hitrightup_p[anim_num];ene->hit_p[4] = &hitleftdown_p[anim_num];ene->hit_p[5] = &hitrightdown_p[anim_num];
  261.         ene->hit_s[2] = &hitleftup_s[anim_num];ene->hit_s[3] = &hitrightup_s[anim_num];ene->hit_s[4] = &hitleftdown_s[anim_num];ene->hit_s[5] = &hitrightdown_s[anim_num];
  262.         ene->parts1->pt=obj_obj+anim_num;
  263.         if( !anim_num ){
  264.             SetSE(SE_TRANSFORM);    /* ガチャン */
  265.             ene->work=1;
  266.             ene->vx=ene->move_ax;        /* 加速度復帰 */
  267.             ene->vy=ene->move_ay;
  268.             ene->anim_count=0;
  269.         }
  270.     }
  271.  
  272.     if( ene->parts1->child_death ){
  273.         MakeEffect(EFFECT_EXPL, 0, ene->x, ene->y);
  274.         SetSE(SE_EXPL_BOSS);    /* 爆発音 */
  275.         MakeEffect (EFFECT_HAHEN, 0, ene->x, ene->y);
  276.         if(!eshot_erase)
  277.             eshot_erase = ESHOT_ERASE;    /* 弾消し */
  278.         ene->player->score += 20;
  279.         ene->parts1->child_kill=1;
  280.         ene->hit_p[0]=NULL;
  281.         ene->dead_count=1;
  282.     }
  283.  
  284.     /* ダメージを受けた時の処理 */
  285.     if(ene->damage){
  286.         SetSE(SE_DAMAGE);    /* 効果音 */
  287.         ene->damage = 0;
  288.     }
  289.  
  290.     xobj_set_st(ene);
  291.     xsp_set_st(ene->parts1);
  292.     xsp_set_st(ene->parts1->parts1);
  293.     xsp_set_st(ene->parts1->parts2);
  294.  
  295.     return(1);
  296. }
  297.  
  298. /*
  299. static void TiniEnemyBoss04(ENEMY * p)
  300. {
  301. }
  302. */
  303.